/**
 * Copyright (C) 2024
 * All rights reserved, Designed By www.joolun.com
 * 注意：
 * 本软件为www.joolun.com开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
import http from "@/api/api";

export function getPage(query) {
  return http.request({
    url: '/mall/goodsspu/page',
    method: 'get',
    params: query
  })
}

export function getCount(query) {
  return http.request({
    url: '/mall/goodsspu/count',
    method: 'get',
    params: query,
	showLoading: false
  })
}

export function addObj(obj) {
  return http.request({
    url: '/mall/goodsspu',
    method: 'post',
    data: obj
  })
}

export function getObj(id) {
  return http.request({
    url: '/mall/goodsspu/' + id,
    method: 'get'
  })
}

export function delObj(id) {
  return http.request({
    url: '/mall/goodsspu/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
  return http.request({
    url: '/mall/goodsspu',
    method: 'put',
    data: obj
  })
}

export function putObjShelf(obj) {
  return http.request({
    url: '/mall/goodsspu/shelf',
    method: 'put',
    params: obj
  })
}

// 根据id获取商品列表详情
export function getListByIds(ids) {
  // 如果空就不获取
  return 0 < ids.length
    ? http.requestNew("post", "/mall/goodsspu/listbyids", { data: ids })
    : new Promise(resolve => {
        resolve({ data: { data: [] } });
      });
}